package com.itts.synchronizedDemo;


/**
 * 测试 synchronized 是可重入锁
 */
public class synchronizedT extends father {
    public static void main(String[] args) {

        new Thread(() -> {
            synchronizedT child = new synchronizedT();
            child.doSomething();
        }).start();
    }

    public synchronized void doSomething() {
        System.out.println("child.doSomething()" + Thread.currentThread().getName());
        doAnotherThing(); // 调用自己类中其他的synchronized方法
    }

    private synchronized void doAnotherThing() {
        super.doSomething(); // 调用父类的synchronized方法
        System.out.println("child.doAnotherThing()" + Thread.currentThread().getName());
    }
}
